<template>
  <el-card>
    <el-form :inline="true">
        <el-form-item label="一级分类" >
      <el-select v-model="categoryStore.c1Id" @change="c1handler" >
        <el-option :label="c1.name" :value="c1.id" v-for="(c1,index) in categoryStore.c1List" :key="c1.id"/>
      </el-select>
    </el-form-item>
    <el-form-item label="二级分类">
      <el-select v-model="categoryStore.c2Id" @change="c2handler" >
        <el-option :label="c2.name" :value="c2.id" v-for="(c2,index) in categoryStore.c2List" :key="c2.id"/>
      </el-select>
    </el-form-item>
    <el-form-item label="三级分类">
      <el-select v-model="categoryStore.c3Id" class="m-2" placeholder="Select" size="large">
        <el-option :label="c3.name" :value="c3.id" v-for="(c3,index) in categoryStore.c3List" :key="c3.id"/>
      </el-select>
    </el-form-item>
    </el-form>
   
  </el-card>
  
</template>

<script setup>
 
import { onMounted, ref } from "vue";
import useCategoryStore  from '../../stores/category'
let categoryStore=useCategoryStore()
onMounted(()=>{
    //通知pinia仓库发请求，获取一级分类的数据
    categoryStore.getC1List()
})

   //通知pinia仓库发请求，获取二级分类的数据
   const c1handler=()=>{
    categoryStore.getC2List()
   }
   //通知pinia仓库发请求，获取三级分类的数据
  const c2handler=()=>{
    categoryStore.getC3List()
   }
    
   
</script>

<style lang="scss" scoped>
</style>